<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增合同附件')" />
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-contractFile-add">
        <input name="contractId" th:value="${contractId}"  id="contractId" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">附件名称：</label>
            <div class="col-sm-8">
                <input id="name" name="contractFileName" class="form-control" type="text" required>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">附件：</label>
            <div class="col-sm-8">
                <input type="hidden" name="path">
                <div class="file-loading">
                    <input class="form-control file-upload" id="path" name="file" type="file">
                </div>
            </div>
        </div>

<!--        <div class="form-group">-->
<!--            <label class="col-sm-3 control-label is-required">路径：</label>-->
<!--            <div class="col-sm-8">-->
<!--                <input name="path" class="form-control" type="text">-->
<!--            </div>-->
<!--        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">类型：</label>
            <div class="col-sm-8">
                <select name="type" class="form-control m-b" th:with="type=${@dict.getType('b_file_type')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">后缀：</label>
            <div class="col-sm-8">
                <select name="suffix" class="form-control m-b" th:with="type=${@dict.getType('b_contrack_file_suffix')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js"/>

<script th:inline="javascript">
    var typeDatas = [[${@dict.getType('b_file_type')}]];
    var suffixDatas = [[${@dict.getType('b_contrack_file_suffix')}]];
    var prefix = ctx + "contract/contractFile"
    $("#form-contractFile-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-contractFile-add').serialize());
        }
    }

    $(".file-upload").fileinput({
        uploadUrl: ctx + 'common/upload',
        maxFileCount: 1,
        autoReplace: true
    }).on('fileuploaded', function (event, data, previewId, index) {
        $("input[name='" + event.currentTarget.id + "']").val(data.response.fileName)
    }).on('fileremoved', function (event, id, index) {
        $("input[name='" + event.currentTarget.id + "']").val('')
    })

</script>
</body>
</html>
